// import type { CSSProperties } from 'vue';
import type { FormProps, ButtonProps, GridProps, GridItemProps } from 'naive-ui';

export interface FormColumn {
  label: string;
  key: string;
  valueType: 'text' | 'select' | 'date' | 'formatDate';
  tooltip?: string;
  slot?: string;
  fieldProps?: any;
  formItemProps?: any;
  rules?: object | object[];
  giProps?: GridItemProps;
  defaultValue?: any;
}

export interface SubmitterProps {
  onSubmit?: any;
  show?: boolean;
  searchConfig?: {
    submitText?: string;
    resetText?: string;
  };
  submitButtonProps?: Partial<ButtonProps>;
  resetButtonProps?: Partial<ButtonProps>;
}

export interface ProFormProps {
  columns: FormColumn[];
  submitter?: SubmitterProps;
  gridProps?: Partial<GridProps>;
  formProps?: Partial<FormProps>;
}

export interface FormActionType {
  submit: () => Promise<any>;
  // setProps: (formProps: Partial<FormProps>) => Promise<void>;
  setFieldsValue: <T>(values: T) => Promise<void>;
  clearValidate: (name?: string | string[]) => Promise<void>;
  getFieldsValue: () => Recordable;
  resetFields: () => Promise<void>;
  validate: (nameList?: any[]) => Promise<any>;
}

export type RegisterFn = (formInstance: FormActionType) => void;

export type UseFormReturnType = [RegisterFn, FormActionType];
